{% extends "base.html" %} {% load static %}
{% block title %} 更新文章 {% endblock title %}
{% block content %}
<div class="container">
    <div class="row">
        <div class="col-12">
            <br>
            <form method="post" action=".">
                {% csrf_token %}
                <div class="form-group">
                    <label for="title">文章标题</label>
                    <!-- 在 value 属性中指定文本框的初始值为旧的内容，即 article 对象中的 title 字段 -->
                    <input type="text" class="form-control" id="title" name="title" value="{{ article.title }}">
                </div>
                <div class="form-group">
                    <label for="column">栏目</label>
                    <select class="form-control" id="column" name="column">
                        <option value="TheGreat">请选择栏目..</option>
                        {% for column in columns %}
                            <option value="{{ column.id }}" 
                                {% if article.column and article.column.id == column.id %}
                                    selected 
                                {% endif %}>
                                {{ column }}
                            </option>
                        {% endfor %}
                    </select>
                        <label for="tags">文章标签</label>
                        {{ article_post_form.tags }}
                        <small class="form-text text-muted">多个标签请用逗号分隔</small>
                    <label for="body">文章正文</label>
                    <!-- 文本域不需要 value 属性，直接在标签体中嵌入数据即可 -->
                    <!-- <textarea type="text" class="form-control" id="body" name="body" rows="12">{{ article.body }}</textarea> -->
                    {{ article_post_form.media }}
                    {{ article_post_form.body }}
                </div>
                <button type="submit" class="btn btn-primary">完成</button>
            </form>
        </div>
    </div>
</div>
{% endblock content %}